<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>倒计时效果</title>
    <style type="text/css">
        .content2{
            text-align: center;
            margin-top: 20%;
        }
        #timeShow{
            font-size: 48px;
            color: blue;
        }
    </style>
    <script type="text/javascript">
window.onload = function () {
    var curtime = new Date();
    var endtime = new Date("2018,6,6");
    var lefttime = Math.ceil((endtime.getTime() - curtime.getTime()) / (24*60*60*1000));
    // 1天 = 24小时 1小时=60分 1分=60秒 1秒=1000毫秒

    //alert(lefttime);
    document.getElementById('timeShow').innerHTML = lefttime;
}
    </script>
</head>

<body>
    <div class="content2">
        <div class="txtshow"><span id="timeShow"></span></div>
    </div>

</body>

</html>